package com.zhangbaiyan.test03;

/**
 * @author zhangbaiyan
 * @date 2024-09-23 12:37
 * @description:
 * @version:
 */
public class MyThread extends Thread{
    //表示这个类所有的对象,都共享ticket数据
   static int ticket=0; //0～99
    @Override
    public void run() {
        while (true){
            if (ticket<=99){
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+"正在卖第"+(++ticket)+"张票");
            }else {
                break;
            }
        }
    }
}
